package com.redhat.redwork.widget.grid;

import java.util.List;

/**
 * 
 * @author Justin
 *
 * @param <Entity>
 * @param <C>
 */
public interface GridModel<Entity, C> {

	/**
	 * to let the grid component know the type of the "search dto"
	 * @return
	 */
	C getCriteriaObject();
	
	/**
	 * 
	 * @param search
	 * @param page
	 * @param pageSize
	 * @param order
	 * @return
	 */
	List<Entity> list(C criteria, int page, int pageSize, Order order);
	
	/**
	 * count result matching criteria 
	 * @param criteria
	 * @return
	 */
	Long count(C criteria);
	
	/**
	 * retrieve one row
	 * @param id
	 * @return
	 */
	Entity get(String id);
	
	/**
	 * create
	 * 
	 * @param entity
	 * @return
	 */
	Entity save(Entity entity);

	/**
	 * update
	 * 
	 * @param entity
	 * @return
	 */
	Entity update(Entity entity);
	/**
	 * delete
	 * 
	 * @param id
	 */
	void delete(String id);
	
}
